//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_x_xai_markers.sqf"
#include "x_setup.sqf"

 private ["_units","_mkname","_mkr","_unit","_plobj","_ai","_unittext","_unitno"];
_mkname = "AI_X%1%2";
_plobj = __getMNsVar2(GVAR(string_player));
if (!isNil "_plobj" && {!isNull _plobj}) then {
	_grppl = group _plobj;
	_units = units _grppl - [player];
	for "_ai" from 2 to 40 do {
		_mkr = format[_mkname, GVAR(string_player), _ai];
		if (_ai - 1 <= count _units) then {
			_unit = _units select _ai - 2;
			if (alive _unit && {!isPlayer _unit}) then {
				_mkr setMarkerAlphaLocal 1;
				_unittext = toArray(str _unit);
				_unitno = toString [_unittext select ((count _unittext) - 1)];
				_mkr setMarkerPosLocal (visiblePositionASL _unit);
				_mkr setMarkerTextLocal (switch (GVAR(show_player_marker)) do {
					case 1: {_unitno};
					case 2: {""};
					case 3: {GVAR(mark_loc280) + str(9 - round(9 * damage _unit))};
					default {""};
				});
				//if (_plobj == player) then {
					//_mkr setMarkerColorLocal "ColorGreen";
				//};
				if (GVAR(p_marker_dirs)) then {_as setMarkerDirLocal (direction (vehicle _unit))};
			} else {
				_mkr setMarkerPosLocal [0,0];
				_mkr setMarkerTextLocal "";
				_mkr setMarkerAlphaLocal 0;
			};
		} else {
			_mkr setMarkerPosLocal [0,0];
			_mkr setMarkerTextLocal "";
			_mkr setMarkerAlphaLocal 0;
		};
	};
};